package com.jzx.provider.cv.repository;

import com.jzx.provider.cv.model.EducationInfo;
import com.jzx.provider.cv.model.WorkInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author daihuihui
 * @date 2019/2/5
 */
public interface WorkInfoRepository extends JpaRepository<WorkInfo, Integer> {
    /**
     * 根据简历id查找工作经历
     *
     * @param cvId 简历id
     * @return 工作经历列表
     */
    List<WorkInfo> findByCvId(Long cvId);

    @Modifying
    @Query(nativeQuery = true, value = "update t_work_info set " +
            "start_date=:#{#workInfo.startDate},end_date=:#{#workInfo.endDate}," +
            "company=:#{#workInfo.company},title=:#{#workInfo.title}," +
            "duties=:#{#workInfo.duties},update_time=:#{#workInfo.updateTime} where id=:#{#workInfo.id}")
    void updateCvWorkInfo(WorkInfo workInfo);
}
